package com.demostic.demostic_test.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.accloud.service.ACUserDevice;
import com.bumptech.glide.Glide;
import com.demostic.demostic_test.R;
import com.demostic.demostic_test.ui.SlidingMenu;
import com.demostic.demostic_test.utils.Constants;
import com.demostic.demostic_test.utils.UserUtils;

import java.util.List;

public class DevListAdapter_new extends RecyclerView.Adapter<DevListAdapter_new.MyViewHolder> {
    private final String TAG = DevListAdapter_new.class.getSimpleName();
    private Context context;
    private List<ACUserDevice> deviceList;
    private LayoutInflater inflater;
    private OnClickListener mOnClickListener;
    private SlidingMenu mOpenMenu;
    private SlidingMenu mScrollingMenu;

    public interface OnClickListener {
        void onContentClick(int i);

        void onMenuClick(int i);
    }

    public SlidingMenu getScrollingMenu() {
        return this.mScrollingMenu;
    }

    public void setScrollingMenu(SlidingMenu scrollingMenu) {
        this.mScrollingMenu = scrollingMenu;
    }

    public void holdOpenMenu(SlidingMenu slidingMenu) {
        this.mOpenMenu = slidingMenu;
    }

    public void closeOpenMenu() {
        if (this.mOpenMenu != null && this.mOpenMenu.isOpen()) {
            this.mOpenMenu.closeMenu();
            this.mOpenMenu = null;
        }
    }

    public DevListAdapter_new(Context context2, List<ACUserDevice> deviceList2) {
        this.context = context2;
        this.deviceList = deviceList2;
        this.inflater = LayoutInflater.from(context2);
    }

    @Override // android.support.v7.widget.RecyclerView.Adapter
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(this.context).inflate(R.layout.device_list_item, parent, false));
    }

    public void onBindViewHolder(MyViewHolder holder, final int position) {
        String subDomain = this.deviceList.get(position).getSubDomain();
        if (subDomain.equals(Constants.subdomain_x420)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_420)).into(holder.image_product);
        } else if (subDomain.equals("zhiyitest")) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_430)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x610)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_610)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x620)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_620)).into(holder.image_product);
        } else if (subDomain.equals("ilifex660") || subDomain.equals("ilifex660")) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_660)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x782)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_782)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x785)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_785)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x786) || subDomain.equals(Constants.subdomain_x787) || subDomain.equals(Constants.subdomain_x790)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.image_x786)).into(holder.image_product);
        } else if (subDomain.equals(Constants.subdomain_x800)) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_800)).into(holder.image_product);
        } else if (subDomain.equals("ilifex900") || subDomain.equals(Constants.subdomain_x901) || subDomain.equals("ilifex900")) {
            Glide.with(this.context).load(Integer.valueOf((int) R.drawable.ap_suc_900)).into(holder.image_product);
        }
        if (TextUtils.isEmpty(this.deviceList.get(position).getName())) {
            holder.tv_name.setText(UserUtils.exChange(this.deviceList.get(position).physicalDeviceId));
        } else {
            holder.tv_name.setText(this.deviceList.get(position).getName());
        }
        int states = this.deviceList.get(position).getStatus();
        if (states == 0 || states == 2) {
            holder.tv_status.setText(this.context.getString(R.string.device_adapter_device_offline));
        } else {
            holder.tv_status.setText(this.context.getString(R.string.device_adapter_device_online));
        }
        holder.item_delete.setOnClickListener(new View.OnClickListener() {
            /* class com.demostic.demostic_test.adapter.DevListAdapter_new.AnonymousClass1 */

            @Override // android.view.View.OnClickListener
            public void onClick(View v) {
                DevListAdapter_new.this.closeOpenMenu();
                if (DevListAdapter_new.this.mOnClickListener != null) {
                    DevListAdapter_new.this.mOnClickListener.onMenuClick(position);
                }
            }
        });
        holder.slidingMenu.setCustomOnClickListener(new SlidingMenu.CustomOnClickListener() {
            /* class com.demostic.demostic_test.adapter.DevListAdapter_new.AnonymousClass2 */

            @Override // com.demostic.demostic_test.ui.SlidingMenu.CustomOnClickListener
            public void onClick() {
                if (DevListAdapter_new.this.mOnClickListener != null) {
                    DevListAdapter_new.this.mOnClickListener.onContentClick(position);
                }
            }
        });
    }

    public void setOnClickListener(OnClickListener onClickListener) {
        this.mOnClickListener = onClickListener;
    }

    @Override // android.support.v7.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.deviceList.size();
    }

    /* access modifiers changed from: package-private */
    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView image_product;
        RelativeLayout item_content;
        TextView item_delete;
        SlidingMenu slidingMenu;
        TextView tv_name;
        TextView tv_status;

        MyViewHolder(View itemView) {
            super(itemView);
            this.tv_name = (TextView) itemView.findViewById(R.id.tv_name);
            this.tv_status = (TextView) itemView.findViewById(R.id.tv_status);
            this.item_delete = (TextView) itemView.findViewById(R.id.item_delete);
            this.image_product = (ImageView) itemView.findViewById(R.id.image_product);
            this.item_content = (RelativeLayout) itemView.findViewById(R.id.item_content);
            this.slidingMenu = (SlidingMenu) itemView.findViewById(R.id.slidingMenu);
        }
    }
}
